class User < ActiveRecord::Base
validates_uniqueness_of :username
  validates_presence_of :password
  validates_confirmation_of :password
 
    
    validates_length_of :password, :within => 2..40

    # If a user matching the credentials is found, returns the User object.
    # If no matching user is found, returns nil.
    def self.authenticate(username,password)
      find_by_username_and_password(username,password)
    end

end
